package com.example.safeassistan.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.example.safeassistan.R;

public class HiddendangerInvestigationDialog extends Dialog {
    private ClickListenerInterface clickListenerInterface;

    public HiddendangerInvestigationDialog(Context context) {
        super(context, R.style.custom_dialog_style);
    }

    public interface ClickListenerInterface {
        void doActivity();
        void doNorelative();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
    }

    private void init() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // 设置不显示键盘
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
        setContentView(R.layout.dialog_hiddendanger_investigation);
        TextView tvActivity = findViewById(R.id.tvActivity);
        TextView tvNorelative = findViewById(R.id.tvNorelative);

        tvActivity.setOnClickListener(new clickListener());
        tvNorelative.setOnClickListener(new clickListener());
        this.setCancelable(false);
        this.setCanceledOnTouchOutside(false);
    }


    public void setClicklistener(ClickListenerInterface clickListener) {
        clickListenerInterface = clickListener;
    }

    private class clickListener implements View.OnClickListener {

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.tvActivity:
                    clickListenerInterface.doActivity();
                    dismiss();
                    break;
                case R.id.tvNorelative:
                    dismiss();
                    clickListenerInterface.doNorelative();
                    break;
            }
        }
    }
}
